<?php
class MobileSendlistServer {
	public function UserBatchSend($userData=array(),$info){
		if (empty($userData)){
			return ERROR_CODE_ONE;
		}
		$tmp = array();
		$time = strtotime("now");
		$info =HttpServerManager::getSendInfoTemplateServer()->getTitleAndContent($info);
		if (!is_array($info)){
			return $info;
		}
		foreach ($userData as $v){
			$tmp1['phone'] = $v['phone'];
			$tmp1['time'] = $time;
			$tmp1['content'] = $info['content'];
			array_push($tmp,$tmp1);
		}
		HttpDaoManager::getMobileSendlistDao()->addArray($tmp);
	} 

	public function instantTexting($phone , $content){
		$number = 0;
		$send = false;
		while ($number<3 || $send==false){
			$send = $this->sendSMS($phone, $content);
			$number++;
		}
		$status  = $send===true?SEND_STATUS_1:SEND_STATUS_2;
		HttpDaoManager::getInstantTextingLogDao()->add(array('phone'=>$phone,'content'=>$content,'time'=>time(),'status'=>$send,'number'=>$number));
	}
	

	public function sendSMS($phone , $content){
		$data['sn'] = 'SDK-BBX-010-17631';
		$data['pwd'] = strtoupper(md5($data['sn'].'466$624-'));
		$data['mobile'] = $phone;
		$data['content'] = mb_convert_encoding($content.'【100课堂】','gb2312','utf-8');
		$data['ext'] = "";
		$data['stime'] = "";
		$data['rrid'] = "";
		//同时存储验证手机
		return  ClassManager::getToos()->request_by_curl('http://sdk.entinfo.cn:8060/webservice.asmx/mt', $data);
	}
}
?>